package com.credithc.customers.manager.controller;

import com.credithc.baseserv.core.codes.CoreCodes;
import com.credithc.baseserv.core.message.Message;
import com.credithc.baseserv.core.message.MessageFactory;
import com.credithc.baseserv.pageHelper.PageInfo;
import com.credithc.customers.base.ro.CustomerRelationInfoRo;
import com.credithc.customers.base.vo.CustomerRelationInfoVo;
import com.credithc.customers.manager.service.CustomerRelationInfoService;
import com.credithc.customers.manager.vo.EChartsRVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @Title: 客户关系详情业务
 * @Author: zhq
 * @Date: 2018/12/14
 * @Description: com.credithc.customers.manager.controller
 * @Version: V1.0.0
 */
@RestController
@RequestMapping("/manager/yzt/v1/customer/relation")
public class CustomerRelationController {
    @Autowired
    CustomerRelationInfoService customerRelationInfoService;
    @Autowired
    MessageFactory messageFactory;
    @GetMapping("/search")
    public Message search(CustomerRelationInfoRo relationRo, @RequestParam("pageNo") Integer pageNo, @RequestParam("pageSize") Integer pageSize) {

        PageInfo<CustomerRelationInfoVo> list = customerRelationInfoService.queryByCustomerRelationInfoRo(relationRo, pageNo, pageSize);
        Map<String, Object> pageInfo = new HashMap<>();
        pageInfo.put("pageInfo", list);
        return messageFactory.getInstance(CoreCodes.CORE_SUCCESS, pageInfo);
    }
    @GetMapping("echarts/relation")
    public Message relation (String customerNo) {
        EChartsRVo customerRelation = customerRelationInfoService.getCustomerRelation(customerNo);
        return messageFactory.getInstance(CoreCodes.CORE_SUCCESS, customerRelation);
    }
    /*@GetMapping("test")
    public String test(){
        customerRelationInfoService.test1();
        return "ok";
    }*/



}
